package com.zzyl.nursing.controller;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.domain.NursingTask;
import com.zzyl.nursing.dto.NursingTaskDto;
import com.zzyl.nursing.dto.TaskDto;
import com.zzyl.nursing.service.INursingTaskService;
import com.zzyl.nursing.vo.NursingTaskVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description NursingTaskController
 * @Author wangyuelong
 * @Date 2025-03-02  16:27
 */
@RestController
@RequestMapping("/nursing/nursingTask")
@Api(tags = "护理任务的接口")
public class NursingTaskController extends BaseController {


    @Autowired
    private INursingTaskService nursingTaskService;



    //查询护理任务列表
    @GetMapping("/list")
    public TableDataInfo nursingTaskPage(NursingTaskDto nursingTask){
        startPage();
        List<NursingTask> list =nursingTaskService.selectAllPage(nursingTask);

        return getDataTable(list);
    }

    //获取护理任务详细信息
    @GetMapping("/{id}")
    public R<NursingTaskVo> nursingTaskById(@PathVariable Long id){

        return R.ok(nursingTaskService.selectNursingTaskById(id));
    }

    //取消任务
    @PutMapping("/cancel")
    public AjaxResult unNursingTask(@RequestBody TaskDto taskDto){
        // System.out.println(taskDto.getTaskId());
        // System.out.println(taskDto.getReason());
        return AjaxResult.success(nursingTaskService.updateNoNursingTask(taskDto));
    }

    //任务执行
    @PutMapping("/do")
    public AjaxResult doNursingTask(@RequestBody TaskDto taskDto){

        return AjaxResult.success(nursingTaskService.updateDoNursingTask(taskDto));
    }

    //任务改期
    @PutMapping("/updateTime")
    public AjaxResult updateNursingTask(@RequestBody TaskDto taskDto){

        return AjaxResult.success(nursingTaskService.updateTimeNursingTask(taskDto));
    }




}
